@extends('admin.common.list.list')
@section('content')
<div class="mws-panel grid_8">
	 <div class="mws-panel-header">
                <span><i class="icon-table"></i> 普通用户列表</span>
                <!-- <a  class="btn btn-success btn-xs"  style="margin-left:930px;margin-top:-50px" href="/admin/user/create">添加用户</a> -->
     </div>
    <div class="mws-panel-body no-padding">
        <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
        <form method="get" action="/admin/user">
	        <div id="DataTables_Table_1_length" class="dataTables_length">
	        	
	        	<label>显示 
	        		<select name="count" aria-controls="DataTables_Table_1">
		        		<option value="10" @if(!empty($request['count']) && $request['count'] == 10) selected @endif>10</option>
		        		<option value="20" @if(!empty($request['count']) && $request['count'] == 20) selected @endif>20</option>
		        		<option value="30" @if(!empty($request['count']) && $request['count'] == 30) selected @endif>30</option>
		        		<option value="50" @if(!empty($request['count']) && $request['count'] == 50) selected @endif>50</option>
		        	</select> 条</label>
		    </div>
		        <div class="dataTables_filter" id="DataTables_Table_1_filter">
		        	<label>用户名搜索: <input type="text" name="search" value="{{$request['search'] or ''}}" aria-controls="DataTables_Table_1"><input type="submit" class="btn btn-success btn-xs" value="搜索"></label>
		        </div>
		</form>
		        <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
		            <thead>
		            	<tr>
		            		<th>id</th>
		            		<th>用户名</th>
		            		<th>手机号</th>
		            		<th>邮箱</th>
		            		<th>用户状态</th>
		            		<th>操作</th>
		            	</tr>
		            </thead>
	            
			        <tbody role="alert" aria-live="polite" aria-relevant="all">
			        		@foreach($custom as $k=>$v)
			        		<tr class="odd" align="center">
			                    <td class="">{{$v->id}}</td>
			                    <td class="">{{$v->u_name}}</td>
			                    <td class="">{{$v->u_phone}}</td>
			                    <td class="">{{$v->u_email}}</td>
			                    <td align="center"><a href="/admin/user/{{$v->id}}" class="btn {{$v->u_dologin==1?'btn-info':'btn-warning'}}">{{$v->u_dologin==1?'开启':'禁用'}}</a></td>
			                    <td class="">
			                    		<a href="javascript:void(0)" class="btn btn-warning" onclick="del({{$v->id}})">删除</a>
			                    	
			                    		<!-- <a href="/admin/user/{{$v->id}}/edit" class="btn btn-info">修改</a> -->
			                    </td>
			                </tr>
			        		@endforeach
			        </tbody>
	        </table>

			<div id="page_page">
				{!! $custom->appends($request)->render()!!}
			</div>

		</div>
    </div>
</div>
<script type="text/javascript">

	function del(id){
		layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.post('{{url('admin/user/')}}/'+id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    
	                //删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });

	}
		

</script>
@endsection